package com.wsx.ones.cloud.activemq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * Created by wangshuaixin on 17/5/14.
 */
@Component
public class MQProvider implements CommandLineRunner {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    @Override
    public void run(String... strings) throws Exception {
        send("hello");
    }

    public void send(String msg) {
        jmsMessagingTemplate.convertAndSend(queue, msg);
    }
}
